package com.lz.demo8;

/**
 * @ClassName Student
 * @Description 学生类
 * @Author 2214361854
 * @Date 2022/5/28 15:03
 * @Version 1.0
 */
public class Student {
    //1.1定义学生的属性
    //1.2 封装学生的属性
    private int id;//学号
    private String name;//姓名
    private char gender;//性别
    private String address;//住址
    private String subject;//科目

    //2.1提供本类的无参构造
    public Student() {
        System.out.println("我是Student的无参构造");
    }

    //2.2提供本类的全参构造
    //右键->Generate->Contructor->Shift全选所有属性->OK
    public Student(int id, String name, char gender, String address, String subject) {
        this.id = id;
        this.name = name;
        this.gender = gender;
        this.address = address;
        this.subject = subject;
        System.out.println("我是Student的全参构造");
    }

    //3.1提供本类的普通方法1
    public void study() {
        System.out.println("学习使我快乐~");
    }

    //3.2提供本类的普通方法2
    public void eat(int n) {
        System.out.println("今天我要干它" + n + "碗大米饭");
    }

    //3.3提供本类的普通方法3
    public String sleep() {
        return "今天又睡了美美的一觉";
    }

    //4.提供本类的一个展示类型与所有属性和属性值的方法
    public void show() {
        System.out.println("Student:[id=" + id + ",name=" + name + ",gender=" + gender + ",address=" + address + ",subject=" + subject + "]");
    }

    //1.3提供属性对应的get与set方法
    //右键->Generate->Getter and setter->Shift全选所有属性->OK
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }
}

